<?php
/**
 * Created by PhpStorm.
 * User: 85210755@qq.com
 * NickName: 柏宇娜
 * Date: 2019/10/14 上午10:25
 */

namespace App\Listener;

use Swoft\Event\Annotation\Mapping\Listener;
use Swoft\Event\EventHandlerInterface;
use Swoft\Event\EventInterface;
use Swoft\Tcp\Server\TcpServerEvent;
use Swoft\Server\SwooleEvent;

/**
 * Class UserSavingListener
 *
 * @since 2.0
 *
 * @Listener(TcpServerEvent::CONNECT)
 */
class TcpConnectListener implements EventHandlerInterface
{
    /**
     * @param EventInterface $event
     */
    public function handle(EventInterface $event): void
    {

        /* @var \Swoole\Server $server */
        $server = $event->getTarget();
        $pos    = __METHOD__;
        echo "handle the event '{$event->getName()}' on the: $pos\n";
        var_dump(
            $event->getParam(0), // fd
            $event->getParam(1) // reactorId
        );
    }
}
